package ec.genetic.impl;

import java.util.Comparator;

public class Chromosome implements Comparable {

	String data;
	double livelihoodRate;
	double fitness;
	double parentPropability;
	int chromosomeNumber;
	
	public Chromosome() {

	}
	
	public Chromosome(String data, int chromosomeNumber) {
		this.data = data;
		this.chromosomeNumber = chromosomeNumber;
	}
	
	
	 @Override
     public int compareTo(Object obj) {
		 Chromosome entry = (Chromosome) obj;
          
           double result = parentPropability - entry.parentPropability;
           if(result != 0) {
                  return (int) (result / Math.abs(result));
           }
          
           return 0;
     }
	
	public void countParentPropability(double probability){
		parentPropability = Math.abs(probability - livelihoodRate);
			
	}

}
